﻿using System;
using Autodesk.Revit.DB;
using HYRevitCode.RevitObjectCompareUtility;
using Autodesk.Revit.DB;
using System.Collections.Generic;


namespace YJKRGeometry
{
    //public class RotationComparer : AngleComparer
    //{
    //    public RotationComparer(XYZ refPoint, XYZ center) : base(refPoint, center)
    //    {
    //    }
    //}


    public class RotationComparer : IComparer<XYZ>
    {
        public RotationComparer(XYZ refPoint, XYZ center)
        {
            this.m_ReferencePoint = refPoint;
            this.m_Center = center;
        }

        public int Compare(XYZ pt1, XYZ pt2)
        {
            XYZ xyz = this.m_ReferencePoint - this.m_Center;
            XYZ xyz2 = pt1 - this.m_Center;
            XYZ xyz3 = pt2 - this.m_Center;
            double num = xyz.AngleOnPlaneTo(xyz2, XYZ.BasisZ);
            if (Math.Abs(num - Math.PI * 2) < 1E-06)
            {
                num = 0.0;
            }
            double num2 = xyz.AngleOnPlaneTo(xyz3, XYZ.BasisZ);
            if (Math.Abs(num2 - Math.PI * 2) < 1E-06)
            {
                num2 = 0.0;
            }
            return num.CompareTo(num2);
        }

        private XYZ m_ReferencePoint;

        private XYZ m_Center;
    }

}
